// 模拟项目数据
export const mockProjects = [
  {
    id: 'project-1',
    name: '华东地区500kV输电线路工程',
    code: 'HD-500kV-2023-001',
    owner: '国家电网华东分部',
    constructionUnit: '华东电力建设第一工程公司',
    designUnit: '电力规划设计研究院',
    supervisionUnit: '华东电力工程监理有限公司',
    startDate: '2023-09-01',
    planned_endDate: '2024-12-31',
    status: 'under_construction',
    voltageLevel: '500kV',
    total_length: 120, // 线路总长度(km)
    total_investment: 560000000, // 总投资(元)
    description: '该项目为华东地区主干电网升级工程，途经3个地级市，包含12处重要跨越点'
  },
  {
    id: 'project-2',
    name: '杭州市萧山区220kV配电网改造',
    code: 'HZ-XS-220kV-2023-005',
    owner: '杭州电力局',
    constructionUnit: '浙江送变电工程有限公司',
    designUnit: '杭州电力设计院',
    supervisionUnit: '浙江电力工程监理公司',
    startDate: '2023-11-15',
    planned_endDate: '2024-06-30',
    status: 'planning',
    voltageLevel: '220kV',
    total_length: 35, // 线路总长度(km)
    total_investment: 120000000, // 总投资(元)
    description: '萧山经济开发区电网扩容改造项目，解决区域用电负荷增长问题'
  }
];

// 模拟接口方法
export const ProjectMock = {
  get: async (id) => {
    await new Promise(resolve => setTimeout(resolve, 300));
    const project = mockProjects.find(item => item.id === id);
    if (!project) {
      throw new Error('未找到指定的项目');
    }
    return project;
  },
  list: async () => {
    await new Promise(resolve => setTimeout(resolve, 300));
    return mockProjects;
  },
  update: async (id, data) => {
    await new Promise(resolve => setTimeout(resolve, 300));
    const index = mockProjects.findIndex(item => item.id === id);
    if (index === -1) {
      throw new Error('更新失败，未找到项目');
    }
    mockProjects[index] = { ...mockProjects[index], ...data };
    return mockProjects[index];
  }
};